/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-07-04 16:09:19
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-07-25 17:19:57
 * @FilePath: /vue3-uniapp/src/utils/assert.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

export const isObject = (data: unknown): data is Record<string, unknown> => {
    return Object.prototype.toString.call(data) === '[object Object]';
};
export const isArray = (data: unknown): data is unknown[] => {
    return Object.prototype.toString.call(data) === '[object Array]';
};

export const isHttpData = (data: unknown): data is HttpResult => {
    return (
        isObject(data) && Reflect.has(data, 'code') && Reflect.has(data, 'msg')
    );
};

export const isError = (data: unknown): data is Error => {
    return data instanceof Error;
};
